mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 04:53:34 +00:00
Remove more unreachable pubs
This commit is contained in:
parent
731b38fa3c
commit
ba8d6d1e4e
39 changed files with 114 additions and 121 deletions
2
.github/workflows/ci.yaml
vendored
2
.github/workflows/ci.yaml
vendored
|
@ -12,7 +12,7 @@ env:
|
||||||
CARGO_NET_RETRY: 10
|
CARGO_NET_RETRY: 10
|
||||||
CI: 1
|
CI: 1
|
||||||
RUST_BACKTRACE: short
|
RUST_BACKTRACE: short
|
||||||
RUSTFLAGS: "-D warnings " # -W unreachable-pub"
|
RUSTFLAGS: "-D warnings -W unreachable-pub"
|
||||||
RUSTUP_MAX_RETRIES: 10
|
RUSTUP_MAX_RETRIES: 10
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|
2
.github/workflows/metrics.yaml
vendored
2
.github/workflows/metrics.yaml
vendored
|
@ -7,7 +7,7 @@ on:
|
||||||
env:
|
env:
|
||||||
CARGO_INCREMENTAL: 0
|
CARGO_INCREMENTAL: 0
|
||||||
CARGO_NET_RETRY: 10
|
CARGO_NET_RETRY: 10
|
||||||
RUSTFLAGS: "-D warnings " # -W unreachable-pub"
|
RUSTFLAGS: "-D warnings -W unreachable-pub"
|
||||||
RUSTUP_MAX_RETRIES: 10
|
RUSTUP_MAX_RETRIES: 10
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|
2
.github/workflows/release.yaml
vendored
2
.github/workflows/release.yaml
vendored
|
@ -11,7 +11,7 @@ on:
|
||||||
env:
|
env:
|
||||||
CARGO_INCREMENTAL: 0
|
CARGO_INCREMENTAL: 0
|
||||||
CARGO_NET_RETRY: 10
|
CARGO_NET_RETRY: 10
|
||||||
RUSTFLAGS: "-D warnings " # -W unreachable-pub"
|
RUSTFLAGS: "-D warnings -W unreachable-pub"
|
||||||
RUSTUP_MAX_RETRIES: 10
|
RUSTUP_MAX_RETRIES: 10
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|
2
.github/workflows/rustdoc.yaml
vendored
2
.github/workflows/rustdoc.yaml
vendored
|
@ -7,7 +7,7 @@ on:
|
||||||
env:
|
env:
|
||||||
CARGO_INCREMENTAL: 0
|
CARGO_INCREMENTAL: 0
|
||||||
CARGO_NET_RETRY: 10
|
CARGO_NET_RETRY: 10
|
||||||
RUSTFLAGS: "-D warnings " # -W unreachable-pub"
|
RUSTFLAGS: "-D warnings -W unreachable-pub"
|
||||||
RUSTUP_MAX_RETRIES: 10
|
RUSTUP_MAX_RETRIES: 10
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|
|
@ -26,13 +26,13 @@ pub(crate) enum ImportCandidate {
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub(crate) struct TraitImportCandidate {
|
pub(crate) struct TraitImportCandidate {
|
||||||
pub ty: hir::Type,
|
pub(crate) ty: hir::Type,
|
||||||
pub name: ast::NameRef,
|
pub(crate) name: ast::NameRef,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub(crate) struct PathImportCandidate {
|
pub(crate) struct PathImportCandidate {
|
||||||
pub name: ast::NameRef,
|
pub(crate) name: ast::NameRef,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|
|
@ -17,13 +17,13 @@ use syntax::{
|
||||||
use test_utils::mark;
|
use test_utils::mark;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum ImportScope {
|
pub(crate) enum ImportScope {
|
||||||
File(ast::SourceFile),
|
File(ast::SourceFile),
|
||||||
Module(ast::ItemList),
|
Module(ast::ItemList),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ImportScope {
|
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()) {
|
if let Some(module) = ast::Module::cast(syntax.clone()) {
|
||||||
module.item_list().map(ImportScope::Module)
|
module.item_list().map(ImportScope::Module)
|
||||||
} else if let this @ Some(_) = ast::SourceFile::cast(syntax.clone()) {
|
} else if let this @ Some(_) = ast::SourceFile::cast(syntax.clone()) {
|
||||||
|
|
|
@ -88,7 +88,7 @@ enum State {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FormatStrParser {
|
impl FormatStrParser {
|
||||||
pub fn new(input: String) -> Self {
|
pub(crate) fn new(input: String) -> Self {
|
||||||
Self {
|
Self {
|
||||||
input: input.into(),
|
input: input.into(),
|
||||||
output: String::new(),
|
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 current_expr = String::new();
|
||||||
|
|
||||||
let mut placeholder_id = 1;
|
let mut placeholder_id = 1;
|
||||||
|
@ -194,7 +194,7 @@ impl FormatStrParser {
|
||||||
Ok(())
|
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");
|
assert!(self.parsed, "Attempt to get a suggestion from not parsed expression");
|
||||||
|
|
||||||
let expressions_as_string = self.extracted_expressions.join(", ");
|
let expressions_as_string = self.extracted_expressions.join(", ");
|
||||||
|
|
|
@ -4,7 +4,6 @@ use std::{iter, sync::Arc};
|
||||||
use arrayvec::ArrayVec;
|
use arrayvec::ArrayVec;
|
||||||
use base_db::{CrateDisplayName, CrateId, Edition, FileId};
|
use base_db::{CrateDisplayName, CrateId, Edition, FileId};
|
||||||
use either::Either;
|
use either::Either;
|
||||||
use hir_def::find_path::PrefixKind;
|
|
||||||
use hir_def::{
|
use hir_def::{
|
||||||
adt::ReprKind,
|
adt::ReprKind,
|
||||||
adt::StructKind,
|
adt::StructKind,
|
||||||
|
@ -12,16 +11,18 @@ use hir_def::{
|
||||||
builtin_type::BuiltinType,
|
builtin_type::BuiltinType,
|
||||||
expr::{BindingAnnotation, Pat, PatId},
|
expr::{BindingAnnotation, Pat, PatId},
|
||||||
import_map,
|
import_map,
|
||||||
|
item_tree::ItemTreeNode,
|
||||||
lang_item::LangItemTarget,
|
lang_item::LangItemTarget,
|
||||||
path::ModPath,
|
path::ModPath,
|
||||||
per_ns::PerNs,
|
per_ns::PerNs,
|
||||||
resolver::{HasResolver, Resolver},
|
resolver::{HasResolver, Resolver},
|
||||||
src::HasSource as _,
|
src::HasSource as _,
|
||||||
type_ref::{Mutability, TypeRef},
|
type_ref::{Mutability, TypeRef},
|
||||||
AdtId, AssocContainerId, AttrDefId, ConstId, DefWithBodyId, EnumId, FunctionId, GenericDefId,
|
AdtId, AssocContainerId, AssocItemId, AssocItemLoc, AttrDefId, ConstId, DefWithBodyId, EnumId,
|
||||||
HasModule, ImplId, LocalEnumVariantId, LocalFieldId, LocalModuleId, Lookup, ModuleId, StaticId,
|
FunctionId, GenericDefId, HasModule, ImplId, LocalEnumVariantId, LocalFieldId, LocalModuleId,
|
||||||
StructId, TraitId, TypeAliasId, TypeParamId, UnionId,
|
Lookup, ModuleId, StaticId, StructId, TraitId, TypeAliasId, TypeParamId, UnionId,
|
||||||
};
|
};
|
||||||
|
use hir_def::{find_path::PrefixKind, item_scope::ItemInNs, visibility::Visibility};
|
||||||
use hir_expand::{
|
use hir_expand::{
|
||||||
diagnostics::DiagnosticSink,
|
diagnostics::DiagnosticSink,
|
||||||
name::{name, AsName},
|
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 {
|
impl Module {
|
||||||
pub(crate) fn new(krate: Crate, crate_module_id: LocalModuleId) -> Module {
|
pub(crate) fn new(krate: Crate, crate_module_id: LocalModuleId) -> Module {
|
||||||
Module { id: ModuleId { krate: krate.id, local_id: crate_module_id } }
|
Module { id: ModuleId { krate: krate.id, local_id: crate_module_id } }
|
||||||
|
|
|
@ -4,13 +4,13 @@
|
||||||
//! are splitting the hir.
|
//! are splitting the hir.
|
||||||
|
|
||||||
use hir_def::{
|
use hir_def::{
|
||||||
expr::PatId, AdtId, AssocItemId, DefWithBodyId, EnumVariantId, FieldId, GenericDefId,
|
expr::PatId, item_scope::ItemInNs, AdtId, AssocItemId, DefWithBodyId, EnumVariantId, FieldId,
|
||||||
ModuleDefId, VariantId,
|
GenericDefId, ModuleDefId, VariantId,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
code_model::ItemInNs, Adt, AssocItem, DefWithBody, EnumVariant, Field, GenericDef, Local,
|
Adt, AssocItem, DefWithBody, EnumVariant, Field, GenericDef, Local, MacroDef, ModuleDef,
|
||||||
MacroDef, ModuleDef, VariantDef,
|
VariantDef,
|
||||||
};
|
};
|
||||||
|
|
||||||
macro_rules! from_id {
|
macro_rules! from_id {
|
||||||
|
|
|
@ -6,6 +6,7 @@ use hir_def::{
|
||||||
src::{HasChildSource, HasSource as _},
|
src::{HasChildSource, HasSource as _},
|
||||||
Lookup, VariantId,
|
Lookup, VariantId,
|
||||||
};
|
};
|
||||||
|
use hir_expand::InFile;
|
||||||
use syntax::ast;
|
use syntax::ast;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -13,8 +14,6 @@ use crate::{
|
||||||
Module, Static, Struct, Trait, TypeAlias, TypeParam, Union,
|
Module, Static, Struct, Trait, TypeAlias, TypeParam, Union,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub use hir_expand::InFile;
|
|
||||||
|
|
||||||
pub trait HasSource {
|
pub trait HasSource {
|
||||||
type Ast;
|
type Ast;
|
||||||
fn source(self, db: &dyn HirDatabase) -> InFile<Self::Ast>;
|
fn source(self, db: &dyn HirDatabase) -> InFile<Self::Ast>;
|
||||||
|
|
|
@ -36,7 +36,7 @@ pub use crate::{
|
||||||
Access, Adt, AsAssocItem, AssocItem, AssocItemContainer, Callable, CallableKind, Const,
|
Access, Adt, AsAssocItem, AssocItem, AssocItemContainer, Callable, CallableKind, Const,
|
||||||
Crate, CrateDependency, DefWithBody, Enum, EnumVariant, Field, FieldSource, Function,
|
Crate, CrateDependency, DefWithBody, Enum, EnumVariant, Field, FieldSource, Function,
|
||||||
GenericDef, HasVisibility, ImplDef, Local, MacroDef, Module, ModuleDef, ScopeDef, Static,
|
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,
|
has_source::HasSource,
|
||||||
semantics::{original_range, PathResolution, Semantics, SemanticsScope},
|
semantics::{original_range, PathResolution, Semantics, SemanticsScope},
|
||||||
|
@ -53,6 +53,7 @@ pub use hir_def::{
|
||||||
nameres::ModuleSource,
|
nameres::ModuleSource,
|
||||||
path::{ModPath, PathKind},
|
path::{ModPath, PathKind},
|
||||||
type_ref::{Mutability, TypeRef},
|
type_ref::{Mutability, TypeRef},
|
||||||
|
visibility::Visibility,
|
||||||
};
|
};
|
||||||
pub use hir_expand::{
|
pub use hir_expand::{
|
||||||
name::known, name::AsName, name::Name, HirFileId, InFile, MacroCallId, MacroCallLoc,
|
name::known, name::AsName, name::Name, HirFileId, InFile, MacroCallId, MacroCallLoc,
|
||||||
|
|
|
@ -5,12 +5,12 @@ use hir_expand::diagnostics::DiagnosticSink;
|
||||||
use crate::diagnostics::InactiveCode;
|
use crate::diagnostics::InactiveCode;
|
||||||
|
|
||||||
#[derive(Debug, Eq, PartialEq)]
|
#[derive(Debug, Eq, PartialEq)]
|
||||||
pub enum BodyDiagnostic {
|
pub(crate) enum BodyDiagnostic {
|
||||||
InactiveCode(InactiveCode),
|
InactiveCode(InactiveCode),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BodyDiagnostic {
|
impl BodyDiagnostic {
|
||||||
pub fn add_to(&self, sink: &mut DiagnosticSink<'_>) {
|
pub(crate) fn add_to(&self, sink: &mut DiagnosticSink<'_>) {
|
||||||
match self {
|
match self {
|
||||||
BodyDiagnostic::InactiveCode(diag) => {
|
BodyDiagnostic::InactiveCode(diag) => {
|
||||||
sink.push(diag.clone());
|
sink.push(diag.clone());
|
||||||
|
|
|
@ -14,7 +14,7 @@ use rustc_hash::FxHashSet;
|
||||||
crate::db::AstDatabaseStorage
|
crate::db::AstDatabaseStorage
|
||||||
)]
|
)]
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct TestDB {
|
pub(crate) struct TestDB {
|
||||||
storage: salsa::Storage<TestDB>,
|
storage: salsa::Storage<TestDB>,
|
||||||
events: Mutex<Option<Vec<salsa::Event>>>,
|
events: Mutex<Option<Vec<salsa::Event>>>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,7 +94,7 @@ enum BindingMode {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BindingMode {
|
impl BindingMode {
|
||||||
pub fn convert(annotation: BindingAnnotation) -> BindingMode {
|
fn convert(annotation: BindingAnnotation) -> BindingMode {
|
||||||
match annotation {
|
match annotation {
|
||||||
BindingAnnotation::Unannotated | BindingAnnotation::Mutable => BindingMode::Move,
|
BindingAnnotation::Unannotated | BindingAnnotation::Mutable => BindingMode::Move,
|
||||||
BindingAnnotation::Ref => BindingMode::Ref(Mutability::Shared),
|
BindingAnnotation::Ref => BindingMode::Ref(Mutability::Shared),
|
||||||
|
|
|
@ -35,7 +35,7 @@ where
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub(super) struct Canonicalized<T> {
|
pub(super) struct Canonicalized<T> {
|
||||||
pub value: Canonical<T>,
|
pub(super) value: Canonical<T>,
|
||||||
free_vars: Vec<InferTy>,
|
free_vars: Vec<InferTy>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ use mapping::{
|
||||||
TypeAliasAsValue,
|
TypeAliasAsValue,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub use self::interner::*;
|
pub(crate) use self::interner::*;
|
||||||
|
|
||||||
pub(super) mod tls;
|
pub(super) mod tls;
|
||||||
mod interner;
|
mod interner;
|
||||||
|
|
|
@ -10,21 +10,21 @@ use std::{fmt, sync::Arc};
|
||||||
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
|
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
|
||||||
pub struct Interner;
|
pub struct Interner;
|
||||||
|
|
||||||
pub type AssocTypeId = chalk_ir::AssocTypeId<Interner>;
|
pub(crate) type AssocTypeId = chalk_ir::AssocTypeId<Interner>;
|
||||||
pub type AssociatedTyDatum = chalk_solve::rust_ir::AssociatedTyDatum<Interner>;
|
pub(crate) type AssociatedTyDatum = chalk_solve::rust_ir::AssociatedTyDatum<Interner>;
|
||||||
pub type ForeignDefId = chalk_ir::ForeignDefId<Interner>;
|
pub(crate) type ForeignDefId = chalk_ir::ForeignDefId<Interner>;
|
||||||
pub type TraitId = chalk_ir::TraitId<Interner>;
|
pub(crate) type TraitId = chalk_ir::TraitId<Interner>;
|
||||||
pub type TraitDatum = chalk_solve::rust_ir::TraitDatum<Interner>;
|
pub(crate) type TraitDatum = chalk_solve::rust_ir::TraitDatum<Interner>;
|
||||||
pub type AdtId = chalk_ir::AdtId<Interner>;
|
pub(crate) type AdtId = chalk_ir::AdtId<Interner>;
|
||||||
pub type StructDatum = chalk_solve::rust_ir::AdtDatum<Interner>;
|
pub(crate) type StructDatum = chalk_solve::rust_ir::AdtDatum<Interner>;
|
||||||
pub type ImplId = chalk_ir::ImplId<Interner>;
|
pub(crate) type ImplId = chalk_ir::ImplId<Interner>;
|
||||||
pub type ImplDatum = chalk_solve::rust_ir::ImplDatum<Interner>;
|
pub(crate) type ImplDatum = chalk_solve::rust_ir::ImplDatum<Interner>;
|
||||||
pub type AssociatedTyValueId = chalk_solve::rust_ir::AssociatedTyValueId<Interner>;
|
pub(crate) type AssociatedTyValueId = chalk_solve::rust_ir::AssociatedTyValueId<Interner>;
|
||||||
pub type AssociatedTyValue = chalk_solve::rust_ir::AssociatedTyValue<Interner>;
|
pub(crate) type AssociatedTyValue = chalk_solve::rust_ir::AssociatedTyValue<Interner>;
|
||||||
pub type FnDefId = chalk_ir::FnDefId<Interner>;
|
pub(crate) type FnDefId = chalk_ir::FnDefId<Interner>;
|
||||||
pub type FnDefDatum = chalk_solve::rust_ir::FnDefDatum<Interner>;
|
pub(crate) type FnDefDatum = chalk_solve::rust_ir::FnDefDatum<Interner>;
|
||||||
pub type OpaqueTyId = chalk_ir::OpaqueTyId<Interner>;
|
pub(crate) type OpaqueTyId = chalk_ir::OpaqueTyId<Interner>;
|
||||||
pub type OpaqueTyDatum = chalk_solve::rust_ir::OpaqueTyDatum<Interner>;
|
pub(crate) type OpaqueTyDatum = chalk_solve::rust_ir::OpaqueTyDatum<Interner>;
|
||||||
|
|
||||||
impl chalk_ir::interner::Interner for Interner {
|
impl chalk_ir::interner::Interner for Interner {
|
||||||
type InternedType = Arc<chalk_ir::TyData<Self>>;
|
type InternedType = Arc<chalk_ir::TyData<Self>>;
|
||||||
|
|
|
@ -464,7 +464,7 @@ impl ToChalk for CallableDefId {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct TypeAliasAsAssocType(pub TypeAliasId);
|
pub(crate) struct TypeAliasAsAssocType(pub(crate) TypeAliasId);
|
||||||
|
|
||||||
impl ToChalk for TypeAliasAsAssocType {
|
impl ToChalk for TypeAliasAsAssocType {
|
||||||
type Chalk = AssocTypeId;
|
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 {
|
impl ToChalk for TypeAliasAsForeignType {
|
||||||
type Chalk = ForeignDefId;
|
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 {
|
impl ToChalk for TypeAliasAsValue {
|
||||||
type Chalk = AssociatedTyValueId;
|
type Chalk = AssociatedTyValueId;
|
||||||
|
|
|
@ -25,7 +25,7 @@ use crate::{diagnostics::Fix, references::rename::rename_with_semantics, FilePos
|
||||||
/// A [Diagnostic] that potentially has a fix available.
|
/// A [Diagnostic] that potentially has a fix available.
|
||||||
///
|
///
|
||||||
/// [Diagnostic]: hir::diagnostics::Diagnostic
|
/// [Diagnostic]: hir::diagnostics::Diagnostic
|
||||||
pub trait DiagnosticWithFix: Diagnostic {
|
pub(crate) trait DiagnosticWithFix: Diagnostic {
|
||||||
fn fix(&self, sema: &Semantics<RootDatabase>) -> Option<Fix>;
|
fn fix(&self, sema: &Semantics<RootDatabase>) -> Option<Fix>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
//! Resolves and rewrites links in markdown documentation.
|
//! Resolves and rewrites links in markdown documentation.
|
||||||
|
|
||||||
use std::convert::TryFrom;
|
use std::{convert::TryFrom, iter::once};
|
||||||
use std::iter::once;
|
|
||||||
|
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use pulldown_cmark::{BrokenLink, CowStr, Event, InlineStr, LinkType, Options, Parser, Tag};
|
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};
|
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)
|
/// 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| {
|
let mut cb = |link: BrokenLink| {
|
||||||
Some((
|
Some((
|
||||||
/*url*/ link.reference.to_owned().into(),
|
/*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.
|
/// 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 drop_link = false;
|
||||||
|
|
||||||
let mut opts = Options::empty();
|
let mut opts = Options::empty();
|
||||||
|
|
|
@ -27,7 +27,7 @@ pub struct StructureNode {
|
||||||
//
|
//
|
||||||
// | VS Code | kbd:[Ctrl+Shift+O]
|
// | 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 res = Vec::new();
|
||||||
let mut stack = Vec::new();
|
let mut stack = Vec::new();
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ use text_edit::{TextEdit, TextEditBuilder};
|
||||||
//
|
//
|
||||||
// | VS Code | **Rust Analyzer: Join lines**
|
// | 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 range = if range.is_empty() {
|
||||||
let syntax = file.syntax();
|
let syntax = file.syntax();
|
||||||
let text = syntax.text().slice(range.start()..);
|
let text = syntax.text().slice(range.start()..);
|
||||||
|
|
|
@ -72,18 +72,20 @@ pub use crate::{
|
||||||
inlay_hints::{InlayHint, InlayHintsConfig, InlayKind},
|
inlay_hints::{InlayHint, InlayHintsConfig, InlayKind},
|
||||||
markup::Markup,
|
markup::Markup,
|
||||||
prime_caches::PrimeCachesProgress,
|
prime_caches::PrimeCachesProgress,
|
||||||
references::{
|
references::{rename::RenameError, Declaration, ReferenceSearchResult},
|
||||||
Declaration, Reference, ReferenceAccess, ReferenceKind, ReferenceSearchResult, RenameError,
|
|
||||||
},
|
|
||||||
runnables::{Runnable, RunnableKind, TestId},
|
runnables::{Runnable, RunnableKind, TestId},
|
||||||
syntax_highlighting::{
|
syntax_highlighting::{
|
||||||
Highlight, HighlightModifier, HighlightModifiers, HighlightTag, HighlightedRange,
|
tags::{Highlight, HighlightModifier, HighlightModifiers, HighlightTag},
|
||||||
|
HighlightedRange,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
pub use completion::{
|
pub use completion::{
|
||||||
CompletionConfig, CompletionItem, CompletionItemKind, CompletionScore, InsertTextFormat,
|
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::{
|
pub use assists::{
|
||||||
utils::MergeBehaviour, Assist, AssistConfig, AssistId, AssistKind, ResolvedAssist,
|
utils::MergeBehaviour, Assist, AssistConfig, AssistId, AssistKind, ResolvedAssist,
|
||||||
|
@ -503,7 +505,7 @@ impl Analysis {
|
||||||
position: FilePosition,
|
position: FilePosition,
|
||||||
new_name: &str,
|
new_name: &str,
|
||||||
) -> Cancelable<Result<RangeInfo<SourceChange>, RenameError>> {
|
) -> 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(
|
pub fn structural_search_replace(
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
//! Removes markdown from strings.
|
//! Removes markdown from strings.
|
||||||
|
|
||||||
use pulldown_cmark::{Event, Parser, Tag};
|
use pulldown_cmark::{Event, Parser, Tag};
|
||||||
|
|
||||||
/// Removes all markdown, keeping the text and code blocks
|
/// Removes all markdown, keeping the text and code blocks
|
||||||
///
|
///
|
||||||
/// Currently limited in styling, i.e. no ascii tables or lists
|
/// 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 mut out = String::new();
|
||||||
let parser = Parser::new(markdown);
|
let parser = Parser::new(markdown);
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ use test_utils::mark;
|
||||||
//
|
//
|
||||||
// | VS Code | **Rust Analyzer: Find matching brace**
|
// | 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] =
|
const BRACES: &[SyntaxKind] =
|
||||||
&[T!['{'], T!['}'], T!['['], T![']'], T!['('], T![')'], T![<], T![>], T![|], T![|]];
|
&[T!['{'], T!['}'], T!['['], T![']'], T!['('], T![')'], T![<], T![>], T![|], T![|]];
|
||||||
let (brace_token, brace_idx) = file
|
let (brace_token, brace_idx) = file
|
||||||
|
|
|
@ -14,7 +14,8 @@ pub(crate) mod rename;
|
||||||
use hir::Semantics;
|
use hir::Semantics;
|
||||||
use ide_db::{
|
use ide_db::{
|
||||||
defs::{Definition, NameClass, NameRefClass},
|
defs::{Definition, NameClass, NameRefClass},
|
||||||
search::SearchScope,
|
search::Reference,
|
||||||
|
search::{ReferenceAccess, ReferenceKind, SearchScope},
|
||||||
RootDatabase,
|
RootDatabase,
|
||||||
};
|
};
|
||||||
use syntax::{
|
use syntax::{
|
||||||
|
@ -25,11 +26,6 @@ use syntax::{
|
||||||
|
|
||||||
use crate::{display::TryToNav, FilePosition, FileRange, NavigationTarget, RangeInfo};
|
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)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct ReferenceSearchResult {
|
pub struct ReferenceSearchResult {
|
||||||
declaration: Declaration,
|
declaration: Declaration,
|
||||||
|
|
|
@ -2,7 +2,7 @@ mod format;
|
||||||
mod html;
|
mod html;
|
||||||
mod injection;
|
mod injection;
|
||||||
mod macro_rules;
|
mod macro_rules;
|
||||||
mod tags;
|
pub(crate) mod tags;
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests;
|
mod tests;
|
||||||
|
|
||||||
|
@ -20,12 +20,13 @@ use syntax::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
syntax_highlighting::{format::FormatStringHighlighter, macro_rules::MacroRulesHighlighter},
|
syntax_highlighting::{
|
||||||
FileId,
|
format::FormatStringHighlighter, macro_rules::MacroRulesHighlighter, tags::Highlight,
|
||||||
|
},
|
||||||
|
FileId, HighlightModifier, HighlightTag,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub(crate) use html::highlight_as_html;
|
pub(crate) use html::highlight_as_html;
|
||||||
pub use tags::{Highlight, HighlightModifier, HighlightModifiers, HighlightTag};
|
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct HighlightedRange {
|
pub struct HighlightedRange {
|
||||||
|
|
|
@ -21,7 +21,7 @@ pub(crate) struct SubtreeTokenSource<'a> {
|
||||||
impl<'a> SubtreeTokenSource<'a> {
|
impl<'a> SubtreeTokenSource<'a> {
|
||||||
// Helper function used in test
|
// Helper function used in test
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
pub fn text(&self) -> SmolStr {
|
pub(crate) fn text(&self) -> SmolStr {
|
||||||
match *self.get(self.curr.1) {
|
match *self.get(self.curr.1) {
|
||||||
Some(ref tt) => tt.text.clone(),
|
Some(ref tt) => tt.text.clone(),
|
||||||
_ => SmolStr::new(""),
|
_ => SmolStr::new(""),
|
||||||
|
|
|
@ -278,13 +278,13 @@ impl CargoWorkspace {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Default)]
|
#[derive(Debug, Clone, Default)]
|
||||||
pub struct ExternResources {
|
pub(crate) struct ExternResources {
|
||||||
out_dirs: FxHashMap<PackageId, AbsPathBuf>,
|
out_dirs: FxHashMap<PackageId, AbsPathBuf>,
|
||||||
proc_dylib_paths: FxHashMap<PackageId, AbsPathBuf>,
|
proc_dylib_paths: FxHashMap<PackageId, AbsPathBuf>,
|
||||||
cfgs: FxHashMap<PackageId, Vec<CfgFlag>>,
|
cfgs: FxHashMap<PackageId, Vec<CfgFlag>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn load_extern_resources(
|
pub(crate) fn load_extern_resources(
|
||||||
cargo_toml: &Path,
|
cargo_toml: &Path,
|
||||||
cargo_features: &CargoConfig,
|
cargo_features: &CargoConfig,
|
||||||
) -> Result<ExternResources> {
|
) -> Result<ExternResources> {
|
||||||
|
|
|
@ -17,7 +17,7 @@ pub struct Sysroot {
|
||||||
crates: Arena<SysrootCrateData>,
|
crates: Arena<SysrootCrateData>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type SysrootCrate = Idx<SysrootCrateData>;
|
pub(crate) type SysrootCrate = Idx<SysrootCrateData>;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Eq, PartialEq)]
|
#[derive(Debug, Clone, Eq, PartialEq)]
|
||||||
pub struct SysrootCrateData {
|
pub struct SysrootCrateData {
|
||||||
|
|
|
@ -81,7 +81,7 @@ mod tracing_setup {
|
||||||
use tracing_subscriber::Registry;
|
use tracing_subscriber::Registry;
|
||||||
use tracing_tree::HierarchicalLayer;
|
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 filter = EnvFilter::from_env("CHALK_DEBUG");
|
||||||
let layer = HierarchicalLayer::default()
|
let layer = HierarchicalLayer::default()
|
||||||
.with_indent_lines(true)
|
.with_indent_lines(true)
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
|
||||||
/// A Simple ASCII Progress Bar
|
/// A Simple ASCII Progress Bar
|
||||||
pub struct ProgressReport {
|
pub(crate) struct ProgressReport {
|
||||||
curr: f32,
|
curr: f32,
|
||||||
text: String,
|
text: String,
|
||||||
hidden: bool,
|
hidden: bool,
|
||||||
|
@ -15,7 +15,7 @@ pub struct ProgressReport {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ProgressReport {
|
impl ProgressReport {
|
||||||
pub fn new(len: u64) -> ProgressReport {
|
pub(crate) fn new(len: u64) -> ProgressReport {
|
||||||
ProgressReport {
|
ProgressReport {
|
||||||
curr: 0.0,
|
curr: 0.0,
|
||||||
text: String::new(),
|
text: String::new(),
|
||||||
|
@ -26,7 +26,7 @@ impl ProgressReport {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn hidden() -> ProgressReport {
|
pub(crate) fn hidden() -> ProgressReport {
|
||||||
ProgressReport {
|
ProgressReport {
|
||||||
curr: 0.0,
|
curr: 0.0,
|
||||||
text: String::new(),
|
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.msg = msg.to_string();
|
||||||
self.tick();
|
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();
|
self.clear();
|
||||||
println!("{}", msg.into());
|
println!("{}", msg.into());
|
||||||
self.tick();
|
self.tick();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn inc(&mut self, delta: u64) {
|
pub(crate) fn inc(&mut self, delta: u64) {
|
||||||
self.pos += delta;
|
self.pos += delta;
|
||||||
if self.len == 0 {
|
if self.len == 0 {
|
||||||
self.set_value(0.0)
|
self.set_value(0.0)
|
||||||
|
@ -58,11 +58,11 @@ impl ProgressReport {
|
||||||
self.tick();
|
self.tick();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn finish_and_clear(&mut self) {
|
pub(crate) fn finish_and_clear(&mut self) {
|
||||||
self.clear();
|
self.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn tick(&mut self) {
|
pub(crate) fn tick(&mut self) {
|
||||||
if self.hidden {
|
if self.hidden {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,11 +6,11 @@
|
||||||
/// client notifications.
|
/// client notifications.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub(crate) struct DocumentData {
|
pub(crate) struct DocumentData {
|
||||||
pub version: Option<i64>,
|
pub(crate) version: Option<i64>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DocumentData {
|
impl DocumentData {
|
||||||
pub fn new(version: i64) -> Self {
|
pub(crate) fn new(version: i64) -> Self {
|
||||||
DocumentData { version: Some(version) }
|
DocumentData { version: Some(version) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,7 +87,7 @@ pub(crate) struct GlobalStateSnapshot {
|
||||||
pub(crate) check_fixes: CheckFixes,
|
pub(crate) check_fixes: CheckFixes,
|
||||||
pub(crate) latest_requests: Arc<RwLock<LatestRequests>>,
|
pub(crate) latest_requests: Arc<RwLock<LatestRequests>>,
|
||||||
mem_docs: FxHashMap<VfsPath, DocumentData>,
|
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>)>>,
|
vfs: Arc<RwLock<(vfs::Vfs, FxHashMap<FileId, LineEndings>)>>,
|
||||||
pub(crate) workspaces: Arc<Vec<ProjectWorkspace>>,
|
pub(crate) workspaces: Arc<Vec<ProjectWorkspace>>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,12 +101,12 @@ pub(crate) struct SemanticTokensBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl 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() }
|
SemanticTokensBuilder { id, prev_line: 0, prev_char: 0, data: Default::default() }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Push a new token onto the builder
|
/// 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_line = range.start.line as u32;
|
||||||
let mut push_char = range.start.character 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;
|
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 }
|
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 offset = new.iter().zip(old.iter()).take_while(|&(n, p)| n == p).count();
|
||||||
|
|
||||||
let (_, old) = old.split_at(offset);
|
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
|
SUPPORTED_TYPES.iter().position(|it| *it == type_).unwrap() as u32
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ use vfs::AbsPathBuf;
|
||||||
|
|
||||||
use crate::testdir::TestDir;
|
use crate::testdir::TestDir;
|
||||||
|
|
||||||
pub struct Project<'a> {
|
pub(crate) struct Project<'a> {
|
||||||
fixture: &'a str,
|
fixture: &'a str,
|
||||||
with_sysroot: bool,
|
with_sysroot: bool,
|
||||||
tmp_dir: Option<TestDir>,
|
tmp_dir: Option<TestDir>,
|
||||||
|
@ -33,11 +33,11 @@ pub struct Project<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> 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 }
|
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.tmp_dir = Some(tmp_dir);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
@ -47,17 +47,17 @@ impl<'a> Project<'a> {
|
||||||
self
|
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.with_sysroot = sysroot;
|
||||||
self
|
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.config = Some(Box::new(config));
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn server(self) -> Server {
|
pub(crate) fn server(self) -> Server {
|
||||||
let tmp_dir = self.tmp_dir.unwrap_or_else(|| TestDir::new());
|
let tmp_dir = self.tmp_dir.unwrap_or_else(|| TestDir::new());
|
||||||
static INIT: Once = Once::new();
|
static INIT: Once = Once::new();
|
||||||
INIT.call_once(|| {
|
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()
|
Project::with_fixture(fixture).server()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Server {
|
pub(crate) struct Server {
|
||||||
req_id: Cell<u64>,
|
req_id: Cell<u64>,
|
||||||
messages: RefCell<Vec<Message>>,
|
messages: RefCell<Vec<Message>>,
|
||||||
_thread: jod_thread::JoinHandle<()>,
|
_thread: jod_thread::JoinHandle<()>,
|
||||||
|
@ -128,12 +128,12 @@ impl Server {
|
||||||
Server { req_id: Cell::new(1), dir, messages: Default::default(), client, _thread }
|
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);
|
let path = self.dir.path().join(rel_path);
|
||||||
TextDocumentIdentifier { uri: Url::from_file_path(path).unwrap() }
|
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
|
where
|
||||||
N: lsp_types::notification::Notification,
|
N: lsp_types::notification::Notification,
|
||||||
N::Params: Serialize,
|
N::Params: Serialize,
|
||||||
|
@ -142,7 +142,7 @@ impl Server {
|
||||||
self.send_notification(r)
|
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
|
where
|
||||||
R: lsp_types::request::Request,
|
R: lsp_types::request::Request,
|
||||||
R::Params: Serialize,
|
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
|
where
|
||||||
R: lsp_types::request::Request,
|
R: lsp_types::request::Request,
|
||||||
R::Params: Serialize,
|
R::Params: Serialize,
|
||||||
|
@ -202,7 +202,7 @@ impl Server {
|
||||||
}
|
}
|
||||||
panic!("no response");
|
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 {
|
self.wait_for_message_cond(1, &|msg: &Message| match msg {
|
||||||
Message::Notification(n) if n.method == "$/progress" => {
|
Message::Notification(n) if n.method == "$/progress" => {
|
||||||
match n.clone().extract::<ProgressParams>("$/progress").unwrap() {
|
match n.clone().extract::<ProgressParams>("$/progress").unwrap() {
|
||||||
|
@ -241,7 +241,7 @@ impl Server {
|
||||||
self.client.sender.send(Message::Notification(not)).unwrap();
|
self.client.sender.send(Message::Notification(not)).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn path(&self) -> &Path {
|
pub(crate) fn path(&self) -> &Path {
|
||||||
self.dir.path()
|
self.dir.path()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,13 +4,13 @@ use std::{
|
||||||
sync::atomic::{AtomicUsize, Ordering},
|
sync::atomic::{AtomicUsize, Ordering},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct TestDir {
|
pub(crate) struct TestDir {
|
||||||
path: PathBuf,
|
path: PathBuf,
|
||||||
keep: bool,
|
keep: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TestDir {
|
impl TestDir {
|
||||||
pub fn new() -> TestDir {
|
pub(crate) fn new() -> TestDir {
|
||||||
let base = std::env::temp_dir().join("testdir");
|
let base = std::env::temp_dir().join("testdir");
|
||||||
let pid = std::process::id();
|
let pid = std::process::id();
|
||||||
|
|
||||||
|
@ -27,11 +27,11 @@ impl TestDir {
|
||||||
panic!("Failed to create a temporary directory")
|
panic!("Failed to create a temporary directory")
|
||||||
}
|
}
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
pub fn keep(mut self) -> TestDir {
|
pub(crate) fn keep(mut self) -> TestDir {
|
||||||
self.keep = true;
|
self.keep = true;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
pub fn path(&self) -> &Path {
|
pub(crate) fn path(&self) -> &Path {
|
||||||
&self.path
|
&self.path
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ pub(crate) struct Placeholder {
|
||||||
|
|
||||||
/// Represents a `$var` in an SSR query.
|
/// Represents a `$var` in an SSR query.
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
pub(crate) struct Var(pub String);
|
pub(crate) struct Var(pub(crate) String);
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||||
pub(crate) enum Constraint {
|
pub(crate) enum Constraint {
|
||||||
|
|
|
@ -120,7 +120,7 @@ impl VfsPath {
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
mod windows_paths {
|
mod windows_paths {
|
||||||
pub trait Encode {
|
pub(crate) trait Encode {
|
||||||
fn encode(&self, buf: &mut Vec<u8>);
|
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 VERBATIM: &str = "\\\\?\\";
|
||||||
const UNC: &str = "UNC";
|
const UNC: &str = "UNC";
|
||||||
const DEVICE: &str = "\\\\.\\";
|
const DEVICE: &str = "\\\\.\\";
|
||||||
|
|
Loading…
Reference in a new issue