Remove more unreachable pubs

This commit is contained in:
Aleksey Kladov 2020-11-02 16:31:38 +01:00
parent 731b38fa3c
commit ba8d6d1e4e
39 changed files with 114 additions and 121 deletions

View file

@ -12,7 +12,7 @@ env:
CARGO_NET_RETRY: 10
CI: 1
RUST_BACKTRACE: short
RUSTFLAGS: "-D warnings " # -W unreachable-pub"
RUSTFLAGS: "-D warnings -W unreachable-pub"
RUSTUP_MAX_RETRIES: 10
jobs:

View file

@ -7,7 +7,7 @@ on:
env:
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10
RUSTFLAGS: "-D warnings " # -W unreachable-pub"
RUSTFLAGS: "-D warnings -W unreachable-pub"
RUSTUP_MAX_RETRIES: 10
jobs:

View file

@ -11,7 +11,7 @@ on:
env:
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10
RUSTFLAGS: "-D warnings " # -W unreachable-pub"
RUSTFLAGS: "-D warnings -W unreachable-pub"
RUSTUP_MAX_RETRIES: 10
jobs:

View file

@ -7,7 +7,7 @@ on:
env:
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10
RUSTFLAGS: "-D warnings " # -W unreachable-pub"
RUSTFLAGS: "-D warnings -W unreachable-pub"
RUSTUP_MAX_RETRIES: 10
jobs:

View file

@ -26,13 +26,13 @@ pub(crate) enum ImportCandidate {
#[derive(Debug)]
pub(crate) struct TraitImportCandidate {
pub ty: hir::Type,
pub name: ast::NameRef,
pub(crate) ty: hir::Type,
pub(crate) name: ast::NameRef,
}
#[derive(Debug)]
pub(crate) struct PathImportCandidate {
pub name: ast::NameRef,
pub(crate) name: ast::NameRef,
}
#[derive(Debug)]

View file

@ -17,13 +17,13 @@ use syntax::{
use test_utils::mark;
#[derive(Debug)]
pub enum ImportScope {
pub(crate) enum ImportScope {
File(ast::SourceFile),
Module(ast::ItemList),
}
impl ImportScope {
pub fn from(syntax: SyntaxNode) -> Option<Self> {
pub(crate) fn from(syntax: SyntaxNode) -> Option<Self> {
if let Some(module) = ast::Module::cast(syntax.clone()) {
module.item_list().map(ImportScope::Module)
} else if let this @ Some(_) = ast::SourceFile::cast(syntax.clone()) {

View file

@ -88,7 +88,7 @@ enum State {
}
impl FormatStrParser {
pub fn new(input: String) -> Self {
pub(crate) fn new(input: String) -> Self {
Self {
input: input.into(),
output: String::new(),
@ -98,7 +98,7 @@ impl FormatStrParser {
}
}
pub fn parse(&mut self) -> Result<(), ()> {
pub(crate) fn parse(&mut self) -> Result<(), ()> {
let mut current_expr = String::new();
let mut placeholder_id = 1;
@ -194,7 +194,7 @@ impl FormatStrParser {
Ok(())
}
pub fn into_suggestion(&self, macro_name: &str) -> String {
pub(crate) fn into_suggestion(&self, macro_name: &str) -> String {
assert!(self.parsed, "Attempt to get a suggestion from not parsed expression");
let expressions_as_string = self.extracted_expressions.join(", ");

View file

@ -4,7 +4,6 @@ use std::{iter, sync::Arc};
use arrayvec::ArrayVec;
use base_db::{CrateDisplayName, CrateId, Edition, FileId};
use either::Either;
use hir_def::find_path::PrefixKind;
use hir_def::{
adt::ReprKind,
adt::StructKind,
@ -12,16 +11,18 @@ use hir_def::{
builtin_type::BuiltinType,
expr::{BindingAnnotation, Pat, PatId},
import_map,
item_tree::ItemTreeNode,
lang_item::LangItemTarget,
path::ModPath,
per_ns::PerNs,
resolver::{HasResolver, Resolver},
src::HasSource as _,
type_ref::{Mutability, TypeRef},
AdtId, AssocContainerId, AttrDefId, ConstId, DefWithBodyId, EnumId, FunctionId, GenericDefId,
HasModule, ImplId, LocalEnumVariantId, LocalFieldId, LocalModuleId, Lookup, ModuleId, StaticId,
StructId, TraitId, TypeAliasId, TypeParamId, UnionId,
AdtId, AssocContainerId, AssocItemId, AssocItemLoc, AttrDefId, ConstId, DefWithBodyId, EnumId,
FunctionId, GenericDefId, HasModule, ImplId, LocalEnumVariantId, LocalFieldId, LocalModuleId,
Lookup, ModuleId, StaticId, StructId, TraitId, TypeAliasId, TypeParamId, UnionId,
};
use hir_def::{find_path::PrefixKind, item_scope::ItemInNs, visibility::Visibility};
use hir_expand::{
diagnostics::DiagnosticSink,
name::{name, AsName},
@ -275,11 +276,6 @@ impl ModuleDef {
}
}
pub use hir_def::{
attr::Attrs, item_scope::ItemInNs, item_tree::ItemTreeNode, visibility::Visibility,
AssocItemId, AssocItemLoc,
};
impl Module {
pub(crate) fn new(krate: Crate, crate_module_id: LocalModuleId) -> Module {
Module { id: ModuleId { krate: krate.id, local_id: crate_module_id } }

View file

@ -4,13 +4,13 @@
//! are splitting the hir.
use hir_def::{
expr::PatId, AdtId, AssocItemId, DefWithBodyId, EnumVariantId, FieldId, GenericDefId,
ModuleDefId, VariantId,
expr::PatId, item_scope::ItemInNs, AdtId, AssocItemId, DefWithBodyId, EnumVariantId, FieldId,
GenericDefId, ModuleDefId, VariantId,
};
use crate::{
code_model::ItemInNs, Adt, AssocItem, DefWithBody, EnumVariant, Field, GenericDef, Local,
MacroDef, ModuleDef, VariantDef,
Adt, AssocItem, DefWithBody, EnumVariant, Field, GenericDef, Local, MacroDef, ModuleDef,
VariantDef,
};
macro_rules! from_id {

View file

@ -6,6 +6,7 @@ use hir_def::{
src::{HasChildSource, HasSource as _},
Lookup, VariantId,
};
use hir_expand::InFile;
use syntax::ast;
use crate::{
@ -13,8 +14,6 @@ use crate::{
Module, Static, Struct, Trait, TypeAlias, TypeParam, Union,
};
pub use hir_expand::InFile;
pub trait HasSource {
type Ast;
fn source(self, db: &dyn HirDatabase) -> InFile<Self::Ast>;

View file

@ -36,7 +36,7 @@ pub use crate::{
Access, Adt, AsAssocItem, AssocItem, AssocItemContainer, Callable, CallableKind, Const,
Crate, CrateDependency, DefWithBody, Enum, EnumVariant, Field, FieldSource, Function,
GenericDef, HasVisibility, ImplDef, Local, MacroDef, Module, ModuleDef, ScopeDef, Static,
Struct, Trait, Type, TypeAlias, TypeParam, Union, VariantDef, Visibility,
Struct, Trait, Type, TypeAlias, TypeParam, Union, VariantDef,
},
has_source::HasSource,
semantics::{original_range, PathResolution, Semantics, SemanticsScope},
@ -53,6 +53,7 @@ pub use hir_def::{
nameres::ModuleSource,
path::{ModPath, PathKind},
type_ref::{Mutability, TypeRef},
visibility::Visibility,
};
pub use hir_expand::{
name::known, name::AsName, name::Name, HirFileId, InFile, MacroCallId, MacroCallLoc,

View file

@ -5,12 +5,12 @@ use hir_expand::diagnostics::DiagnosticSink;
use crate::diagnostics::InactiveCode;
#[derive(Debug, Eq, PartialEq)]
pub enum BodyDiagnostic {
pub(crate) enum BodyDiagnostic {
InactiveCode(InactiveCode),
}
impl BodyDiagnostic {
pub fn add_to(&self, sink: &mut DiagnosticSink<'_>) {
pub(crate) fn add_to(&self, sink: &mut DiagnosticSink<'_>) {
match self {
BodyDiagnostic::InactiveCode(diag) => {
sink.push(diag.clone());

View file

@ -14,7 +14,7 @@ use rustc_hash::FxHashSet;
crate::db::AstDatabaseStorage
)]
#[derive(Default)]
pub struct TestDB {
pub(crate) struct TestDB {
storage: salsa::Storage<TestDB>,
events: Mutex<Option<Vec<salsa::Event>>>,
}

View file

@ -94,7 +94,7 @@ enum BindingMode {
}
impl BindingMode {
pub fn convert(annotation: BindingAnnotation) -> BindingMode {
fn convert(annotation: BindingAnnotation) -> BindingMode {
match annotation {
BindingAnnotation::Unannotated | BindingAnnotation::Mutable => BindingMode::Move,
BindingAnnotation::Ref => BindingMode::Ref(Mutability::Shared),

View file

@ -35,7 +35,7 @@ where
#[derive(Debug)]
pub(super) struct Canonicalized<T> {
pub value: Canonical<T>,
pub(super) value: Canonical<T>,
free_vars: Vec<InferTy>,
}

View file

@ -27,7 +27,7 @@ use mapping::{
TypeAliasAsValue,
};
pub use self::interner::*;
pub(crate) use self::interner::*;
pub(super) mod tls;
mod interner;

View file

@ -10,21 +10,21 @@ use std::{fmt, sync::Arc};
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct Interner;
pub type AssocTypeId = chalk_ir::AssocTypeId<Interner>;
pub type AssociatedTyDatum = chalk_solve::rust_ir::AssociatedTyDatum<Interner>;
pub type ForeignDefId = chalk_ir::ForeignDefId<Interner>;
pub type TraitId = chalk_ir::TraitId<Interner>;
pub type TraitDatum = chalk_solve::rust_ir::TraitDatum<Interner>;
pub type AdtId = chalk_ir::AdtId<Interner>;
pub type StructDatum = chalk_solve::rust_ir::AdtDatum<Interner>;
pub type ImplId = chalk_ir::ImplId<Interner>;
pub type ImplDatum = chalk_solve::rust_ir::ImplDatum<Interner>;
pub type AssociatedTyValueId = chalk_solve::rust_ir::AssociatedTyValueId<Interner>;
pub type AssociatedTyValue = chalk_solve::rust_ir::AssociatedTyValue<Interner>;
pub type FnDefId = chalk_ir::FnDefId<Interner>;
pub type FnDefDatum = chalk_solve::rust_ir::FnDefDatum<Interner>;
pub type OpaqueTyId = chalk_ir::OpaqueTyId<Interner>;
pub type OpaqueTyDatum = chalk_solve::rust_ir::OpaqueTyDatum<Interner>;
pub(crate) type AssocTypeId = chalk_ir::AssocTypeId<Interner>;
pub(crate) type AssociatedTyDatum = chalk_solve::rust_ir::AssociatedTyDatum<Interner>;
pub(crate) type ForeignDefId = chalk_ir::ForeignDefId<Interner>;
pub(crate) type TraitId = chalk_ir::TraitId<Interner>;
pub(crate) type TraitDatum = chalk_solve::rust_ir::TraitDatum<Interner>;
pub(crate) type AdtId = chalk_ir::AdtId<Interner>;
pub(crate) type StructDatum = chalk_solve::rust_ir::AdtDatum<Interner>;
pub(crate) type ImplId = chalk_ir::ImplId<Interner>;
pub(crate) type ImplDatum = chalk_solve::rust_ir::ImplDatum<Interner>;
pub(crate) type AssociatedTyValueId = chalk_solve::rust_ir::AssociatedTyValueId<Interner>;
pub(crate) type AssociatedTyValue = chalk_solve::rust_ir::AssociatedTyValue<Interner>;
pub(crate) type FnDefId = chalk_ir::FnDefId<Interner>;
pub(crate) type FnDefDatum = chalk_solve::rust_ir::FnDefDatum<Interner>;
pub(crate) type OpaqueTyId = chalk_ir::OpaqueTyId<Interner>;
pub(crate) type OpaqueTyDatum = chalk_solve::rust_ir::OpaqueTyDatum<Interner>;
impl chalk_ir::interner::Interner for Interner {
type InternedType = Arc<chalk_ir::TyData<Self>>;

View file

@ -464,7 +464,7 @@ impl ToChalk for CallableDefId {
}
}
pub struct TypeAliasAsAssocType(pub TypeAliasId);
pub(crate) struct TypeAliasAsAssocType(pub(crate) TypeAliasId);
impl ToChalk for TypeAliasAsAssocType {
type Chalk = AssocTypeId;
@ -478,7 +478,7 @@ impl ToChalk for TypeAliasAsAssocType {
}
}
pub struct TypeAliasAsForeignType(pub TypeAliasId);
pub(crate) struct TypeAliasAsForeignType(pub(crate) TypeAliasId);
impl ToChalk for TypeAliasAsForeignType {
type Chalk = ForeignDefId;
@ -492,7 +492,7 @@ impl ToChalk for TypeAliasAsForeignType {
}
}
pub struct TypeAliasAsValue(pub TypeAliasId);
pub(crate) struct TypeAliasAsValue(pub(crate) TypeAliasId);
impl ToChalk for TypeAliasAsValue {
type Chalk = AssociatedTyValueId;

View file

@ -25,7 +25,7 @@ use crate::{diagnostics::Fix, references::rename::rename_with_semantics, FilePos
/// A [Diagnostic] that potentially has a fix available.
///
/// [Diagnostic]: hir::diagnostics::Diagnostic
pub trait DiagnosticWithFix: Diagnostic {
pub(crate) trait DiagnosticWithFix: Diagnostic {
fn fix(&self, sema: &Semantics<RootDatabase>) -> Option<Fix>;
}

View file

@ -1,7 +1,6 @@
//! Resolves and rewrites links in markdown documentation.
use std::convert::TryFrom;
use std::iter::once;
use std::{convert::TryFrom, iter::once};
use itertools::Itertools;
use pulldown_cmark::{BrokenLink, CowStr, Event, InlineStr, LinkType, Options, Parser, Tag};
@ -21,10 +20,10 @@ use syntax::{ast, match_ast, AstNode, SyntaxKind::*, SyntaxToken, TokenAtOffset,
use crate::{FilePosition, Semantics};
pub type DocumentationLink = String;
pub(crate) type DocumentationLink = String;
/// Rewrite documentation links in markdown to point to an online host (e.g. docs.rs)
pub fn rewrite_links(db: &RootDatabase, markdown: &str, definition: &Definition) -> String {
pub(crate) fn rewrite_links(db: &RootDatabase, markdown: &str, definition: &Definition) -> String {
let mut cb = |link: BrokenLink| {
Some((
/*url*/ link.reference.to_owned().into(),
@ -63,7 +62,7 @@ pub fn rewrite_links(db: &RootDatabase, markdown: &str, definition: &Definition)
}
/// Remove all links in markdown documentation.
pub fn remove_links(markdown: &str) -> String {
pub(crate) fn remove_links(markdown: &str) -> String {
let mut drop_link = false;
let mut opts = Options::empty();

View file

@ -27,7 +27,7 @@ pub struct StructureNode {
//
// | VS Code | kbd:[Ctrl+Shift+O]
// |===
pub fn file_structure(file: &SourceFile) -> Vec<StructureNode> {
pub(crate) fn file_structure(file: &SourceFile) -> Vec<StructureNode> {
let mut res = Vec::new();
let mut stack = Vec::new();

View file

@ -18,7 +18,7 @@ use text_edit::{TextEdit, TextEditBuilder};
//
// | VS Code | **Rust Analyzer: Join lines**
// |===
pub fn join_lines(file: &SourceFile, range: TextRange) -> TextEdit {
pub(crate) fn join_lines(file: &SourceFile, range: TextRange) -> TextEdit {
let range = if range.is_empty() {
let syntax = file.syntax();
let text = syntax.text().slice(range.start()..);

View file

@ -72,18 +72,20 @@ pub use crate::{
inlay_hints::{InlayHint, InlayHintsConfig, InlayKind},
markup::Markup,
prime_caches::PrimeCachesProgress,
references::{
Declaration, Reference, ReferenceAccess, ReferenceKind, ReferenceSearchResult, RenameError,
},
references::{rename::RenameError, Declaration, ReferenceSearchResult},
runnables::{Runnable, RunnableKind, TestId},
syntax_highlighting::{
Highlight, HighlightModifier, HighlightModifiers, HighlightTag, HighlightedRange,
tags::{Highlight, HighlightModifier, HighlightModifiers, HighlightTag},
HighlightedRange,
},
};
pub use completion::{
CompletionConfig, CompletionItem, CompletionItemKind, CompletionScore, InsertTextFormat,
};
pub use ide_db::call_info::CallInfo;
pub use ide_db::{
call_info::CallInfo,
search::{Reference, ReferenceAccess, ReferenceKind},
};
pub use assists::{
utils::MergeBehaviour, Assist, AssistConfig, AssistId, AssistKind, ResolvedAssist,
@ -503,7 +505,7 @@ impl Analysis {
position: FilePosition,
new_name: &str,
) -> Cancelable<Result<RangeInfo<SourceChange>, RenameError>> {
self.with_db(|db| references::rename(db, position, new_name))
self.with_db(|db| references::rename::rename(db, position, new_name))
}
pub fn structural_search_replace(

View file

@ -1,11 +1,10 @@
//! Removes markdown from strings.
use pulldown_cmark::{Event, Parser, Tag};
/// Removes all markdown, keeping the text and code blocks
///
/// Currently limited in styling, i.e. no ascii tables or lists
pub fn remove_markdown(markdown: &str) -> String {
pub(crate) fn remove_markdown(markdown: &str) -> String {
let mut out = String::new();
let parser = Parser::new(markdown);

View file

@ -15,7 +15,7 @@ use test_utils::mark;
//
// | VS Code | **Rust Analyzer: Find matching brace**
// |===
pub fn matching_brace(file: &SourceFile, offset: TextSize) -> Option<TextSize> {
pub(crate) fn matching_brace(file: &SourceFile, offset: TextSize) -> Option<TextSize> {
const BRACES: &[SyntaxKind] =
&[T!['{'], T!['}'], T!['['], T![']'], T!['('], T![')'], T![<], T![>], T![|], T![|]];
let (brace_token, brace_idx) = file

View file

@ -14,7 +14,8 @@ pub(crate) mod rename;
use hir::Semantics;
use ide_db::{
defs::{Definition, NameClass, NameRefClass},
search::SearchScope,
search::Reference,
search::{ReferenceAccess, ReferenceKind, SearchScope},
RootDatabase,
};
use syntax::{
@ -25,11 +26,6 @@ use syntax::{
use crate::{display::TryToNav, FilePosition, FileRange, NavigationTarget, RangeInfo};
pub(crate) use self::rename::rename;
pub use self::rename::RenameError;
pub use ide_db::search::{Reference, ReferenceAccess, ReferenceKind};
#[derive(Debug, Clone)]
pub struct ReferenceSearchResult {
declaration: Declaration,

View file

@ -2,7 +2,7 @@ mod format;
mod html;
mod injection;
mod macro_rules;
mod tags;
pub(crate) mod tags;
#[cfg(test)]
mod tests;
@ -20,12 +20,13 @@ use syntax::{
};
use crate::{
syntax_highlighting::{format::FormatStringHighlighter, macro_rules::MacroRulesHighlighter},
FileId,
syntax_highlighting::{
format::FormatStringHighlighter, macro_rules::MacroRulesHighlighter, tags::Highlight,
},
FileId, HighlightModifier, HighlightTag,
};
pub(crate) use html::highlight_as_html;
pub use tags::{Highlight, HighlightModifier, HighlightModifiers, HighlightTag};
#[derive(Debug, Clone)]
pub struct HighlightedRange {

View file

@ -21,7 +21,7 @@ pub(crate) struct SubtreeTokenSource<'a> {
impl<'a> SubtreeTokenSource<'a> {
// Helper function used in test
#[cfg(test)]
pub fn text(&self) -> SmolStr {
pub(crate) fn text(&self) -> SmolStr {
match *self.get(self.curr.1) {
Some(ref tt) => tt.text.clone(),
_ => SmolStr::new(""),

View file

@ -278,13 +278,13 @@ impl CargoWorkspace {
}
#[derive(Debug, Clone, Default)]
pub struct ExternResources {
pub(crate) struct ExternResources {
out_dirs: FxHashMap<PackageId, AbsPathBuf>,
proc_dylib_paths: FxHashMap<PackageId, AbsPathBuf>,
cfgs: FxHashMap<PackageId, Vec<CfgFlag>>,
}
pub fn load_extern_resources(
pub(crate) fn load_extern_resources(
cargo_toml: &Path,
cargo_features: &CargoConfig,
) -> Result<ExternResources> {

View file

@ -17,7 +17,7 @@ pub struct Sysroot {
crates: Arena<SysrootCrateData>,
}
pub type SysrootCrate = Idx<SysrootCrateData>;
pub(crate) type SysrootCrate = Idx<SysrootCrateData>;
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct SysrootCrateData {

View file

@ -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)

View file

@ -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;
}

View file

@ -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) }
}
}

View file

@ -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>>,
}

View file

@ -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
}

View file

@ -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()
}
}

View file

@ -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
}
}

View file

@ -42,7 +42,7 @@ pub(crate) struct Placeholder {
/// Represents a `$var` in an SSR query.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub(crate) struct Var(pub String);
pub(crate) struct Var(pub(crate) String);
#[derive(Clone, Debug, PartialEq, Eq)]
pub(crate) enum Constraint {

View file

@ -120,7 +120,7 @@ impl VfsPath {
#[cfg(windows)]
mod windows_paths {
pub trait Encode {
pub(crate) trait Encode {
fn encode(&self, buf: &mut Vec<u8>);
}
@ -149,7 +149,7 @@ mod windows_paths {
}
}
pub const SEP: &str = "\\";
pub(crate) const SEP: &str = "\\";
const VERBATIM: &str = "\\\\?\\";
const UNC: &str = "UNC";
const DEVICE: &str = "\\\\.\\";