Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 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
3 changes: 2 additions & 1 deletion .claude/settings.local.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"Bash(cargo test:*)",
"Bash(cargo run:*)",
"Bash(cargo check:*)",
"Bash(cargo fmt:*)"
"Bash(cargo fmt:*)",
"Bash(cargo doc:*)"
],
"deny": []
}
Expand Down
148 changes: 141 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 2 additions & 16 deletions crates/pgt_cli/src/execute/process_file/workspace_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ use crate::execute::diagnostics::{ResultExt, ResultIoExt};
use crate::execute::process_file::SharedTraversalOptions;
use pgt_diagnostics::{Error, category};
use pgt_fs::{File, OpenOptions, PgTPath};
use pgt_workspace::workspace::{ChangeParams, FileGuard, OpenFileParams};
use pgt_workspace::workspace::{FileGuard, OpenFileParams};
use pgt_workspace::{Workspace, WorkspaceError};
use std::path::{Path, PathBuf};

/// Small wrapper that holds information and operations around the current processed file
pub(crate) struct WorkspaceFile<'ctx, 'app> {
guard: FileGuard<'app, dyn Workspace + 'ctx>,
#[allow(dead_code)]
file: Box<dyn File>,
pub(crate) path: PathBuf,
}
Expand Down Expand Up @@ -57,19 +58,4 @@ impl<'ctx, 'app> WorkspaceFile<'ctx, 'app> {
pub(crate) fn input(&self) -> Result<String, WorkspaceError> {
self.guard().get_file_content()
}

/// It updates the workspace file with `new_content`
#[allow(dead_code)]
pub(crate) fn update_file(&mut self, new_content: impl Into<String>) -> Result<(), Error> {
let new_content = new_content.into();

self.file
.set_content(new_content.as_bytes())
.with_file_path(self.path.display().to_string())?;
self.guard.change_file(
self.file.file_version(),
vec![ChangeParams::overwrite(new_content)],
)?;
Ok(())
}
}
4 changes: 1 addition & 3 deletions crates/pgt_lsp/src/capabilities.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::adapters::{PositionEncoding, WideEncoding, negotiated_encoding};
use crate::handlers::code_actions::command_id;
use pgt_workspace::features::code_actions::CommandActionCategory;
use strum::IntoEnumIterator;
use tower_lsp::lsp_types::{
Expand All @@ -7,8 +8,6 @@ use tower_lsp::lsp_types::{
TextDocumentSyncOptions, TextDocumentSyncSaveOptions, WorkDoneProgressOptions,
};

use crate::handlers::code_actions::command_id;

/// The capabilities to send from server as part of [`InitializeResult`]
///
/// [`InitializeResult`]: lspower::lsp::InitializeResult
Expand Down Expand Up @@ -54,7 +53,6 @@ pub(crate) fn server_capabilities(capabilities: &ClientCapabilities) -> ServerCa
commands: CommandActionCategory::iter()
.map(|c| command_id(&c))
.collect::<Vec<String>>(),

..Default::default()
}),
document_formatting_provider: None,
Expand Down
Loading
Loading