Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit fa18370

Browse files
fix: files.ignore setting should work (#462)
1 parent c0567ec commit fa18370

File tree

10 files changed

+231
-13
lines changed

10 files changed

+231
-13
lines changed

‎Cargo.lock

Lines changed: 12 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ convert_case = "0.6.0"
4747
prost-reflect = "0.15.3"
4848
protox = "0.8.0"
4949
sqlx = { version = "0.8.2", features = ["runtime-tokio", "runtime-async-std", "postgres", "json"] }
50-
syn = "1.0.109"
50+
syn = { version = "1.0.109", features = ["full"] }
5151
termcolor = "1.4.1"
5252
test-log = "0.2.17"
5353
tokio = { version = "1.40.0", features = ["full"] }
@@ -85,6 +85,7 @@ pgt_tokenizer = { path = "./crates/pgt_tokenizer", version = "0.0.0
8585
pgt_treesitter_queries = { path = "./crates/pgt_treesitter_queries", version = "0.0.0" }
8686
pgt_typecheck = { path = "./crates/pgt_typecheck", version = "0.0.0" }
8787
pgt_workspace = { path = "./crates/pgt_workspace", version = "0.0.0" }
88+
pgt_workspace_macros = { path = "./crates/pgt_workspace_macros", version = "0.0.0" }
8889

8990
pgt_test_macros = { path = "./crates/pgt_test_macros" }
9091
pgt_test_utils = { path = "./crates/pgt_test_utils" }

‎crates/pgt_diagnostics/src/serde.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ impl From<super::Location<'_>> for Location {
164164
#[serde(rename_all = "camelCase")]
165165
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
166166
#[cfg_attr(test, derive(Eq, PartialEq))]
167+
167168
struct Advices {
168169
advices: Vec<Advice>,
169170
}
@@ -250,7 +251,7 @@ impl super::Advices for Advices {
250251
#[derive(Clone, Debug, Serialize, Deserialize)]
251252
#[serde(rename_all = "camelCase")]
252253
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
253-
#[cfg_attr(test, derive(Eq,PartialEq))]
254+
#[cfg_attr(test, derive(PartialEq,Eq))]
254255
enum Advice {
255256
Log(LogCategory, MarkupBuf),
256257
List(Vec<MarkupBuf>),

‎crates/pgt_workspace/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ pgt_statement_splitter = { workspace = true }
3232
pgt_suppressions = { workspace = true }
3333
pgt_text_size.workspace = true
3434
pgt_typecheck = { workspace = true }
35+
pgt_workspace_macros = { workspace = true }
3536
rustc-hash = { workspace = true }
3637
schemars = { workspace = true, optional = true }
3738
serde = { workspace = true, features = ["derive"] }

‎crates/pgt_workspace/src/features/code_actions.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub struct CodeActionsParams {
1212
pub skip: Vec<RuleSelector>,
1313
}
1414

15-
#[derive(Debug, serde::Serialize, serde::Deserialize)]
15+
#[derive(Debug, serde::Serialize, serde::Deserialize,Default)]
1616
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1717
pub struct CodeActionsResult {
1818
pub actions: Vec<CodeAction>,
@@ -57,7 +57,7 @@ pub struct ExecuteStatementParams {
5757
pub path: PgTPath,
5858
}
5959

60-
#[derive(Debug, serde::Serialize, serde::Deserialize)]
60+
#[derive(Debug, serde::Serialize, serde::Deserialize,Default,PartialEq,Eq)]
6161
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
6262
pub struct ExecuteStatementResult {
6363
pub message: String,

‎crates/pgt_workspace/src/features/diagnostics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub struct PullDiagnosticsParams {
1212
pub skip: Vec<RuleSelector>,
1313
}
1414

15-
#[derive(Debug, serde::Serialize, serde::Deserialize)]
15+
#[derive(Debug, serde::Serialize, serde::Deserialize,Default)]
1616
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1717
pub struct PullDiagnosticsResult {
1818
pub diagnostics: Vec<pgt_diagnostics::serde::Diagnostic>,

‎crates/pgt_workspace/src/workspace/server.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use pgt_diagnostics::{
2121
};
2222
use pgt_fs::{ConfigName, PgTPath};
2323
use pgt_typecheck::{IdentifierType, TypecheckParams, TypedIdentifier};
24+
use pgt_workspace_macros::ignored_path;
2425
use schema_cache_manager::SchemaCacheManager;
2526
use sqlx::{Executor, PgPool};
2627
use tracing::{debug, info};
@@ -30,7 +31,7 @@ use crate::{
3031
configuration::to_analyser_rules,
3132
features::{
3233
code_actions::{
33-
self,CodeAction, CodeActionKind, CodeActionsResult, CommandAction,
34+
CodeAction, CodeActionKind,CodeActionsParams, CodeActionsResult, CommandAction,
3435
CommandActionCategory, ExecuteStatementParams, ExecuteStatementResult,
3536
},
3637
completions::{CompletionsResult, GetCompletionsParams, get_statement_for_completions},
@@ -262,6 +263,7 @@ impl Workspace for WorkspaceServer {
262263
}
263264

264265
/// Add a new file to the workspace
266+
#[ignored_path(path=&params.path)]
265267
#[tracing::instrument(level = "info", skip_all, fields(path = params.path.as_path().as_os_str().to_str()), err)]
266268
fn open_file(&self, params: OpenFileParams) -> Result<(), WorkspaceError> {
267269
let mut documents = self.documents.write().unwrap();
@@ -277,6 +279,7 @@ impl Workspace for WorkspaceServer {
277279
}
278280

279281
/// Remove a file from the workspace
282+
#[ignored_path(path=&params.path)]
280283
fn close_file(&self, params: super::CloseFileParams) -> Result<(), WorkspaceError> {
281284
let mut documents = self.documents.write().unwrap();
282285
documents
@@ -291,6 +294,7 @@ impl Workspace for WorkspaceServer {
291294
path = params.path.as_os_str().to_str(),
292295
version = params.version
293296
), err)]
297+
#[ignored_path(path=&params.path)]
294298
fn change_file(&self, params: super::ChangeFileParams) -> Result<(), WorkspaceError> {
295299
let mut documents = self.documents.write().unwrap();
296300

@@ -312,6 +316,7 @@ impl Workspace for WorkspaceServer {
312316
None
313317
}
314318

319+
#[ignored_path(path=&params.path)]
315320
fn get_file_content(&self, params: GetFileContentParams) -> Result<String, WorkspaceError> {
316321
let documents = self.documents.read().unwrap();
317322
let document = documents
@@ -324,10 +329,11 @@ impl Workspace for WorkspaceServer {
324329
Ok(self.is_ignored(params.pgt_path.as_path()))
325330
}
326331

332+
#[ignored_path(path=&params.path)]
327333
fn pull_code_actions(
328334
&self,
329-
params: code_actions::CodeActionsParams,
330-
) -> Result<code_actions::CodeActionsResult, WorkspaceError> {
335+
params: CodeActionsParams,
336+
) -> Result<CodeActionsResult, WorkspaceError> {
331337
let documents = self.documents.read().unwrap();
332338
let parser = documents
333339
.get(&params.path)
@@ -366,6 +372,7 @@ impl Workspace for WorkspaceServer {
366372
Ok(CodeActionsResult { actions })
367373
}
368374

375+
#[ignored_path(path=&params.path)]
369376
fn execute_statement(
370377
&self,
371378
params: ExecuteStatementParams,
@@ -409,6 +416,7 @@ impl Workspace for WorkspaceServer {
409416
})
410417
}
411418

419+
#[ignored_path(path=&params.path)]
412420
fn pull_diagnostics(
413421
&self,
414422
params: PullDiagnosticsParams,
@@ -607,6 +615,7 @@ impl Workspace for WorkspaceServer {
607615
})
608616
}
609617

618+
#[ignored_path(path=&params.path)]
610619
#[tracing::instrument(level = "debug", skip_all, fields(
611620
path = params.path.as_os_str().to_str(),
612621
position = params.position.to_string()

‎crates/pgt_workspace/src/workspace/server.tests.rs

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
1-
use biome_deserialize::Merge;
1+
use std::sync::Arc;
2+
3+
use biome_deserialize::{Merge, StringSet};
24
use pgt_analyse::RuleCategories;
3-
use pgt_configuration::{PartialConfiguration, database::PartialDatabaseConfiguration};
5+
use pgt_configuration::{
6+
PartialConfiguration, database::PartialDatabaseConfiguration, files::PartialFilesConfiguration,
7+
};
48
use pgt_diagnostics::Diagnostic;
59
use pgt_fs::PgTPath;
610
use pgt_text_size::TextRange;
711
use sqlx::PgPool;
812

913
use crate::{
1014
Workspace, WorkspaceError,
15+
features::code_actions::ExecuteStatementResult,
1116
workspace::{
12-
OpenFileParams, RegisterProjectFolderParams, UpdateSettingsParams, server::WorkspaceServer,
17+
OpenFileParams, RegisterProjectFolderParams, StatementId, UpdateSettingsParams,
18+
server::WorkspaceServer,
1319
},
1420
};
1521

@@ -152,3 +158,51 @@ async fn test_syntax_error(test_db: PgPool) {
152158
Some(TextRange::new(7.into(), 15.into()))
153159
);
154160
}
161+
162+
#[tokio::test]
163+
async fn correctly_ignores_files() {
164+
let mut conf = PartialConfiguration::init();
165+
conf.merge_with(PartialConfiguration {
166+
files: Some(PartialFilesConfiguration {
167+
ignore: Some(StringSet::from_iter(["test.sql".to_string()])),
168+
..Default::default()
169+
}),
170+
..Default::default()
171+
});
172+
173+
let workspace = get_test_workspace(Some(conf)).expect("Unable to create test workspace");
174+
175+
let path = PgTPath::new("test.sql");
176+
let content = r#"
177+
seect 1;
178+
"#;
179+
180+
let diagnostics_result = workspace.pull_diagnostics(crate::workspace::PullDiagnosticsParams {
181+
path: path.clone(),
182+
categories: RuleCategories::all(),
183+
max_diagnostics: 100,
184+
only: vec![],
185+
skip: vec![],
186+
});
187+
188+
assert!(
189+
diagnostics_result.is_ok_and(|res| res.diagnostics.is_empty()
190+
&& res.errors == 0
191+
&& res.skipped_diagnostics == 0)
192+
);
193+
194+
let close_file_result =
195+
workspace.close_file(crate::workspace::CloseFileParams { path: path.clone() });
196+
197+
assert!(close_file_result.is_ok());
198+
199+
let execute_statement_result =
200+
workspace.execute_statement(crate::workspace::ExecuteStatementParams {
201+
path: path.clone(),
202+
statement_id: StatementId::Root {
203+
content: Arc::from(content),
204+
},
205+
});
206+
207+
assert!(execute_statement_result.is_ok_and(|res| res == ExecuteStatementResult::default()));
208+
}

‎crates/pgt_workspace_macros/Cargo.toml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[package]
2+
authors.workspace = true
3+
categories.workspace = true
4+
description = "<DESCRIPTION>"
5+
edition.workspace = true
6+
homepage.workspace = true
7+
keywords.workspace = true
8+
license.workspace = true
9+
name = "pgt_workspace_macros"
10+
repository.workspace = true
11+
version = "0.0.0"
12+
13+
[lib]
14+
proc-macro = true
15+
16+
[dependencies]
17+
proc-macro2 = { version = "1.0.95" }
18+
quote = { workspace = true }
19+
syn = { workspace = true }

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /