mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 06:11:35 +00:00
Remove more unreachable pubs
This commit is contained in:
parent
731b38fa3c
commit
ba8d6d1e4e
39 changed files with 114 additions and 121 deletions
|
@ -81,7 +81,7 @@ mod tracing_setup {
|
|||
use tracing_subscriber::Registry;
|
||||
use tracing_tree::HierarchicalLayer;
|
||||
|
||||
pub fn setup_tracing() -> super::Result<()> {
|
||||
pub(crate) fn setup_tracing() -> super::Result<()> {
|
||||
let filter = EnvFilter::from_env("CHALK_DEBUG");
|
||||
let layer = HierarchicalLayer::default()
|
||||
.with_indent_lines(true)
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
use std::io::Write;
|
||||
|
||||
/// A Simple ASCII Progress Bar
|
||||
pub struct ProgressReport {
|
||||
pub(crate) struct ProgressReport {
|
||||
curr: f32,
|
||||
text: String,
|
||||
hidden: bool,
|
||||
|
@ -15,7 +15,7 @@ pub struct ProgressReport {
|
|||
}
|
||||
|
||||
impl ProgressReport {
|
||||
pub fn new(len: u64) -> ProgressReport {
|
||||
pub(crate) fn new(len: u64) -> ProgressReport {
|
||||
ProgressReport {
|
||||
curr: 0.0,
|
||||
text: String::new(),
|
||||
|
@ -26,7 +26,7 @@ impl ProgressReport {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn hidden() -> ProgressReport {
|
||||
pub(crate) fn hidden() -> ProgressReport {
|
||||
ProgressReport {
|
||||
curr: 0.0,
|
||||
text: String::new(),
|
||||
|
@ -37,18 +37,18 @@ impl ProgressReport {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn set_message(&mut self, msg: &str) {
|
||||
pub(crate) fn set_message(&mut self, msg: &str) {
|
||||
self.msg = msg.to_string();
|
||||
self.tick();
|
||||
}
|
||||
|
||||
pub fn println<I: Into<String>>(&mut self, msg: I) {
|
||||
pub(crate) fn println<I: Into<String>>(&mut self, msg: I) {
|
||||
self.clear();
|
||||
println!("{}", msg.into());
|
||||
self.tick();
|
||||
}
|
||||
|
||||
pub fn inc(&mut self, delta: u64) {
|
||||
pub(crate) fn inc(&mut self, delta: u64) {
|
||||
self.pos += delta;
|
||||
if self.len == 0 {
|
||||
self.set_value(0.0)
|
||||
|
@ -58,11 +58,11 @@ impl ProgressReport {
|
|||
self.tick();
|
||||
}
|
||||
|
||||
pub fn finish_and_clear(&mut self) {
|
||||
pub(crate) fn finish_and_clear(&mut self) {
|
||||
self.clear();
|
||||
}
|
||||
|
||||
pub fn tick(&mut self) {
|
||||
pub(crate) fn tick(&mut self) {
|
||||
if self.hidden {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -6,11 +6,11 @@
|
|||
/// client notifications.
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct DocumentData {
|
||||
pub version: Option<i64>,
|
||||
pub(crate) version: Option<i64>,
|
||||
}
|
||||
|
||||
impl DocumentData {
|
||||
pub fn new(version: i64) -> Self {
|
||||
pub(crate) fn new(version: i64) -> Self {
|
||||
DocumentData { version: Some(version) }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ pub(crate) struct GlobalStateSnapshot {
|
|||
pub(crate) check_fixes: CheckFixes,
|
||||
pub(crate) latest_requests: Arc<RwLock<LatestRequests>>,
|
||||
mem_docs: FxHashMap<VfsPath, DocumentData>,
|
||||
pub semantic_tokens_cache: Arc<Mutex<FxHashMap<Url, SemanticTokens>>>,
|
||||
pub(crate) semantic_tokens_cache: Arc<Mutex<FxHashMap<Url, SemanticTokens>>>,
|
||||
vfs: Arc<RwLock<(vfs::Vfs, FxHashMap<FileId, LineEndings>)>>,
|
||||
pub(crate) workspaces: Arc<Vec<ProjectWorkspace>>,
|
||||
}
|
||||
|
|
|
@ -101,12 +101,12 @@ pub(crate) struct SemanticTokensBuilder {
|
|||
}
|
||||
|
||||
impl SemanticTokensBuilder {
|
||||
pub fn new(id: String) -> Self {
|
||||
pub(crate) fn new(id: String) -> Self {
|
||||
SemanticTokensBuilder { id, prev_line: 0, prev_char: 0, data: Default::default() }
|
||||
}
|
||||
|
||||
/// Push a new token onto the builder
|
||||
pub fn push(&mut self, range: Range, token_index: u32, modifier_bitset: u32) {
|
||||
pub(crate) fn push(&mut self, range: Range, token_index: u32, modifier_bitset: u32) {
|
||||
let mut push_line = range.start.line as u32;
|
||||
let mut push_char = range.start.character as u32;
|
||||
|
||||
|
@ -134,12 +134,12 @@ impl SemanticTokensBuilder {
|
|||
self.prev_char = range.start.character as u32;
|
||||
}
|
||||
|
||||
pub fn build(self) -> SemanticTokens {
|
||||
pub(crate) fn build(self) -> SemanticTokens {
|
||||
SemanticTokens { result_id: Some(self.id), data: self.data }
|
||||
}
|
||||
}
|
||||
|
||||
pub fn diff_tokens(old: &[SemanticToken], new: &[SemanticToken]) -> Vec<SemanticTokensEdit> {
|
||||
pub(crate) fn diff_tokens(old: &[SemanticToken], new: &[SemanticToken]) -> Vec<SemanticTokensEdit> {
|
||||
let offset = new.iter().zip(old.iter()).take_while(|&(n, p)| n == p).count();
|
||||
|
||||
let (_, old) = old.split_at(offset);
|
||||
|
@ -165,7 +165,7 @@ pub fn diff_tokens(old: &[SemanticToken], new: &[SemanticToken]) -> Vec<Semantic
|
|||
}
|
||||
}
|
||||
|
||||
pub fn type_index(type_: SemanticTokenType) -> u32 {
|
||||
pub(crate) fn type_index(type_: SemanticTokenType) -> u32 {
|
||||
SUPPORTED_TYPES.iter().position(|it| *it == type_).unwrap() as u32
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ use vfs::AbsPathBuf;
|
|||
|
||||
use crate::testdir::TestDir;
|
||||
|
||||
pub struct Project<'a> {
|
||||
pub(crate) struct Project<'a> {
|
||||
fixture: &'a str,
|
||||
with_sysroot: bool,
|
||||
tmp_dir: Option<TestDir>,
|
||||
|
@ -33,11 +33,11 @@ pub struct Project<'a> {
|
|||
}
|
||||
|
||||
impl<'a> Project<'a> {
|
||||
pub fn with_fixture(fixture: &str) -> Project {
|
||||
pub(crate) fn with_fixture(fixture: &str) -> Project {
|
||||
Project { fixture, tmp_dir: None, roots: vec![], with_sysroot: false, config: None }
|
||||
}
|
||||
|
||||
pub fn tmp_dir(mut self, tmp_dir: TestDir) -> Project<'a> {
|
||||
pub(crate) fn tmp_dir(mut self, tmp_dir: TestDir) -> Project<'a> {
|
||||
self.tmp_dir = Some(tmp_dir);
|
||||
self
|
||||
}
|
||||
|
@ -47,17 +47,17 @@ impl<'a> Project<'a> {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn with_sysroot(mut self, sysroot: bool) -> Project<'a> {
|
||||
pub(crate) fn with_sysroot(mut self, sysroot: bool) -> Project<'a> {
|
||||
self.with_sysroot = sysroot;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_config(mut self, config: impl Fn(&mut Config) + 'static) -> Project<'a> {
|
||||
pub(crate) fn with_config(mut self, config: impl Fn(&mut Config) + 'static) -> Project<'a> {
|
||||
self.config = Some(Box::new(config));
|
||||
self
|
||||
}
|
||||
|
||||
pub fn server(self) -> Server {
|
||||
pub(crate) fn server(self) -> Server {
|
||||
let tmp_dir = self.tmp_dir.unwrap_or_else(|| TestDir::new());
|
||||
static INIT: Once = Once::new();
|
||||
INIT.call_once(|| {
|
||||
|
@ -103,11 +103,11 @@ impl<'a> Project<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn project(fixture: &str) -> Server {
|
||||
pub(crate) fn project(fixture: &str) -> Server {
|
||||
Project::with_fixture(fixture).server()
|
||||
}
|
||||
|
||||
pub struct Server {
|
||||
pub(crate) struct Server {
|
||||
req_id: Cell<u64>,
|
||||
messages: RefCell<Vec<Message>>,
|
||||
_thread: jod_thread::JoinHandle<()>,
|
||||
|
@ -128,12 +128,12 @@ impl Server {
|
|||
Server { req_id: Cell::new(1), dir, messages: Default::default(), client, _thread }
|
||||
}
|
||||
|
||||
pub fn doc_id(&self, rel_path: &str) -> TextDocumentIdentifier {
|
||||
pub(crate) fn doc_id(&self, rel_path: &str) -> TextDocumentIdentifier {
|
||||
let path = self.dir.path().join(rel_path);
|
||||
TextDocumentIdentifier { uri: Url::from_file_path(path).unwrap() }
|
||||
}
|
||||
|
||||
pub fn notification<N>(&self, params: N::Params)
|
||||
pub(crate) fn notification<N>(&self, params: N::Params)
|
||||
where
|
||||
N: lsp_types::notification::Notification,
|
||||
N::Params: Serialize,
|
||||
|
@ -142,7 +142,7 @@ impl Server {
|
|||
self.send_notification(r)
|
||||
}
|
||||
|
||||
pub fn request<R>(&self, params: R::Params, expected_resp: Value)
|
||||
pub(crate) fn request<R>(&self, params: R::Params, expected_resp: Value)
|
||||
where
|
||||
R: lsp_types::request::Request,
|
||||
R::Params: Serialize,
|
||||
|
@ -159,7 +159,7 @@ impl Server {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn send_request<R>(&self, params: R::Params) -> Value
|
||||
pub(crate) fn send_request<R>(&self, params: R::Params) -> Value
|
||||
where
|
||||
R: lsp_types::request::Request,
|
||||
R::Params: Serialize,
|
||||
|
@ -202,7 +202,7 @@ impl Server {
|
|||
}
|
||||
panic!("no response");
|
||||
}
|
||||
pub fn wait_until_workspace_is_loaded(self) -> Server {
|
||||
pub(crate) fn wait_until_workspace_is_loaded(self) -> Server {
|
||||
self.wait_for_message_cond(1, &|msg: &Message| match msg {
|
||||
Message::Notification(n) if n.method == "$/progress" => {
|
||||
match n.clone().extract::<ProgressParams>("$/progress").unwrap() {
|
||||
|
@ -241,7 +241,7 @@ impl Server {
|
|||
self.client.sender.send(Message::Notification(not)).unwrap();
|
||||
}
|
||||
|
||||
pub fn path(&self) -> &Path {
|
||||
pub(crate) fn path(&self) -> &Path {
|
||||
self.dir.path()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,13 +4,13 @@ use std::{
|
|||
sync::atomic::{AtomicUsize, Ordering},
|
||||
};
|
||||
|
||||
pub struct TestDir {
|
||||
pub(crate) struct TestDir {
|
||||
path: PathBuf,
|
||||
keep: bool,
|
||||
}
|
||||
|
||||
impl TestDir {
|
||||
pub fn new() -> TestDir {
|
||||
pub(crate) fn new() -> TestDir {
|
||||
let base = std::env::temp_dir().join("testdir");
|
||||
let pid = std::process::id();
|
||||
|
||||
|
@ -27,11 +27,11 @@ impl TestDir {
|
|||
panic!("Failed to create a temporary directory")
|
||||
}
|
||||
#[allow(unused)]
|
||||
pub fn keep(mut self) -> TestDir {
|
||||
pub(crate) fn keep(mut self) -> TestDir {
|
||||
self.keep = true;
|
||||
self
|
||||
}
|
||||
pub fn path(&self) -> &Path {
|
||||
pub(crate) fn path(&self) -> &Path {
|
||||
&self.path
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue