pub struct KotlinFile {
pub package: String,
pub decls: Vec<KtDecl>,
pub extra_imports: Vec<String>,
pub banner: Option<String>,
}Expand description
One Kotlin source file fragment: a package plus top-level declarations.
Fragments of the same package are merged by super::file::merge_files.
Fields§
§package: String§decls: Vec<KtDecl>§extra_imports: Vec<String>FQNs referenced only inside raw text the model can’t see (e.g. body strings built with pre-shortened type names). Registered into the file’s import set before any declaration renders.
Override the banner line prepended to the rendered file.
None uses the default banner constant from the renderer. Some("") suppresses it.
Implementations§
Source§impl KtFile
impl KtFile
pub fn new(package: impl Into<String>) -> KtFile
Override the banner comment prepended to the rendered file.
Pass "" to suppress the banner entirely.
pub fn decl(self, d: impl Into<KtDecl>) -> KtFile
Sourcepub fn import(self, fqn: impl Into<String>) -> KtFile
pub fn import(self, fqn: impl Into<String>) -> KtFile
Register an FQN referenced only inside raw text.
pub fn imports(self, fqns: impl IntoIterator<Item = String>) -> KtFile
Source§impl KtFile
impl KtFile
Sourcepub fn validate(&self) -> Vec<Diagnostic>
pub fn validate(&self) -> Vec<Diagnostic>
Every problem in this file, with each check at its default severity (error).
An empty result means the file is as good as the model can prove:
names, redeclarations and declaration shapes are checked, and Check
enumerates exactly which. Anything needing type resolution, or reading
the raw text inside KtCode bodies, stays the Kotlin
compiler’s job.
Sourcepub fn validate_with(&self, policy: &ValidationPolicy) -> Vec<Diagnostic>
pub fn validate_with(&self, policy: &ValidationPolicy) -> Vec<Diagnostic>
KtFile::validate with per-check severities.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for KtFile
impl RefUnwindSafe for KtFile
impl Send for KtFile
impl Sync for KtFile
impl Unpin for KtFile
impl UnsafeUnpin for KtFile
impl UnwindSafe for KtFile
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more