Struct SwiftFormatter
pub struct SwiftFormatter;Expand description
Formatter for Swift/SPM ecosystem LSP responses.
Trait Implementations§
§impl DiagnosticMessages for SwiftFormatter
impl DiagnosticMessages for SwiftFormatter
§fn yanked_message(&self) -> &'static str
fn yanked_message(&self) -> &'static str
§fn yanked_label(&self) -> &'static str
fn yanked_label(&self) -> &'static str
Source§fn deprecated_message(&self) -> &'static str
fn deprecated_message(&self) -> &'static str
Source§fn deprecated_label(&self) -> &'static str
fn deprecated_label(&self) -> &'static str
§impl DiagnosticPolicy for SwiftFormatter
impl DiagnosticPolicy for SwiftFormatter
§fn strict_semver_prerelease_exclusion(&self) -> bool
fn strict_semver_prerelease_exclusion(&self) -> bool
semver::VersionReq::matches excludes pre-releases unless requirement itself pins
to the same X.Y.Z tuple with a pre-release tag — strict SemVer 2.0.0 semantics (#299).
Source§fn supports_package_rename(&self) -> bool
fn supports_package_rename(&self) -> bool
crate::Deprecation::replacement)
is safe to offer as a “Replace with X” rename quickfix. Read moreSource§fn yanked_diagnostic_applies_to(
&self,
_dep: &dyn Dependency,
_requirement: &VersionReq,
) -> bool
fn yanked_diagnostic_applies_to( &self, _dep: &dyn Dependency, _requirement: &VersionReq, ) -> bool
crate::lsp_helpers::requirement_matches_only_yanked) should evaluate requirement
at all for this ecosystem. Read more§impl OsvNaming for SwiftFormatter
impl OsvNaming for SwiftFormatter
§fn osv_package_name(&self, dep: &dyn Dependency) -> Option<String>
fn osv_package_name(&self, dep: &dyn Dependency) -> Option<String>
Raw dep.name(), NOT Self::normalize_package_name: that
lowercases, and OSV’s SwiftURL matching is case-sensitive, so
lowercasing would mangle mixed-case repos. Gated on the dependency’s
source host being github.com: only that host is populated in OSV’s
SwiftURL ecosystem, and dep.name()’s owner/repo shape alone
cannot distinguish a GitHub coordinate from a same-shaped GitLab/self-hosted
one — attributing a GitHub project’s advisories to an unrelated
same-named repo elsewhere would be a false positive, not just a miss.
Source§fn osv_version_to_native(&self, version: &str) -> String
fn osv_version_to_native(&self, version: &str) -> String
crate::osv::Advisory::fixed_versions) into this ecosystem’s
own version namespace, as used in manifests and by the registry. Read more§impl PackageNaming for SwiftFormatter
impl PackageNaming for SwiftFormatter
§fn validate_package_name(&self, name: &str) -> Result<(), InvalidPackageName>
fn validate_package_name(&self, name: &str) -> Result<(), InvalidPackageName>
Accepts either is_valid_owner_repo’s owner/repo GitHub identifier shape (the same
one package_url and the registry’s fetch-URL gate require), or a bare single-segment
name with no /.
The bare-name case matters because name is not always a GitHub coordinate to begin
with: deps_swift::parser’s .package(path:) handling sets it to the target
directory’s basename (crates/deps-swift/src/parser.rs, the RE_PATH arm) for a
DependencySource::Path dependency, which never contains a / and has no GitHub
identity at all. validate_package_name only sees the bare string, not the
dependency’s source, so it cannot tell a local package’s basename apart from a
registry-style name typo’d without its owner/ prefix — per this trait’s “err on the
side of accepting anything ambiguous” contract, the bare form is accepted rather than
flagged, which also fixes a false “Invalid package name” on every local Swift package
dependency (#402 critique C1). A multi-segment name (extra segment, disallowed
character, or a ./.. segment) still fails the owner/repo check and is rejected,
same as before.
§Errors
Returns InvalidPackageName when name is empty, is exactly ./.., or contains a
/ without matching the owner/repo shape.
§fn normalize_package_name(&self, name: &PackageName) -> String
fn normalize_package_name(&self, name: &PackageName) -> String
§impl PackageRendering for SwiftFormatter
impl PackageRendering for SwiftFormatter
§fn format_version_for_text_edit(&self, version: &ConcreteVersion) -> String
fn format_version_for_text_edit(&self, version: &ConcreteVersion) -> String
§fn package_url(&self, name: &PackageName) -> String
fn package_url(&self, name: &PackageName) -> String
Source§fn format_version_replacing(
&self,
version: &ConcreteVersion,
_current: &str,
) -> String
fn format_version_replacing( &self, version: &ConcreteVersion, _current: &str, ) -> String
version as a replacement for the existing requirement text
current, preserving current’s operator/pin style where the
ecosystem supports more than one. Read moreSource§fn format_version_replacing_for(
&self,
_dep: &dyn Dependency,
version: &ConcreteVersion,
current: &str,
) -> String
fn format_version_replacing_for( &self, _dep: &dyn Dependency, version: &ConcreteVersion, current: &str, ) -> String
format_version_replacing, but also
carries the dependency identity version/current apply to. Read moreSource§fn suppress_package_url(&self, source: &DependencySource) -> bool
fn suppress_package_url(&self, source: &DependencySource) -> bool
Self::package_url’s heading link for a dependency
resolved against source. Read moreSource§fn is_position_on_dependency(
&self,
dep: &dyn Dependency,
position: Position,
) -> bool
fn is_position_on_dependency( &self, dep: &dyn Dependency, position: Position, ) -> bool
§impl RequirementResolution for SwiftFormatter
impl RequirementResolution for SwiftFormatter
§fn compile_requirement(
&self,
requirement: &VersionReq,
) -> Option<Box<dyn RequirementMatcher>>
fn compile_requirement( &self, requirement: &VersionReq, ) -> Option<Box<dyn RequirementMatcher>>
Compiles requirement via semver::VersionReq, the same crate
version_satisfies_requirement uses. None on parse failure is the fallible-parse
shape of compile_requirement’s “undecidable” contract (see
deps_core::lsp_helpers::RequirementResolution::compile_requirement) — Swift’s registry client follows GitHub
tags pagination to build available, so a None here is purely “this requirement
string doesn’t parse as semver,” not a gap in what pagination could return.
§fn version_satisfies_requirement(
&self,
version: &ConcreteVersion,
requirement: &str,
) -> bool
fn version_satisfies_requirement( &self, version: &ConcreteVersion, requirement: &str, ) -> bool
Source§fn is_requirement_up_to_date(
&self,
requirement: &VersionReq,
latest: &ConcreteVersion,
) -> bool
fn is_requirement_up_to_date( &self, requirement: &VersionReq, latest: &ConcreteVersion, ) -> bool
latest, given its declared requirement. Read moreSource§fn requirement_is_unresolved(&self, _requirement: &VersionReq) -> bool
fn requirement_is_unresolved(&self, _requirement: &VersionReq) -> bool
requirement could not be resolved to a concrete version constraint (e.g. an
unexpanded property/variable placeholder rather than a real version or range). Read moreSource§fn requirement_status(
&self,
requirement: &VersionReq,
latest: &ConcreteVersion,
) -> RequirementStatus
fn requirement_status( &self, requirement: &VersionReq, latest: &ConcreteVersion, ) -> RequirementStatus
is_requirement_up_to_date that distinguishes “confirmed up to
date” from “could not be resolved, so we don’t know.” Read moreSource§fn requirement_status_for(
&self,
dep: &dyn Dependency,
requirement: &VersionReq,
latest: &ConcreteVersion,
) -> RequirementStatus
fn requirement_status_for( &self, dep: &dyn Dependency, requirement: &VersionReq, latest: &ConcreteVersion, ) -> RequirementStatus
requirement_status, but also hands the ecosystem
the dependency itself — for an ecosystem whose requirement text alone is ambiguous
between two shapes with different resolution rules, and which already computed the
disambiguating classification once, at parse time, onto the dependency (deps-gitlab-ci’s
PinStyle, #466 review M-c: a bare "1.2" is Partial under its component: pin
grammar but Branch under its simpler project: ref grammar — indistinguishable from
the text alone). Read moreSource§fn requirement_is_undecidable_given_available(
&self,
_requirement: &VersionReq,
_available: &[ConcreteVersion],
) -> bool
fn requirement_is_undecidable_given_available( &self, _requirement: &VersionReq, _available: &[ConcreteVersion], ) -> bool
available in a way indistinguishable from “never published” — and, if so, whether
requirement names a version-space region that specific omission could explain, given
the versions actually observed in available. Read moreSource§fn manifest_requirement_is_resolved_version(&self, dep: &dyn Dependency) -> bool
fn manifest_requirement_is_resolved_version(&self, dep: &dyn Dependency) -> bool
dep’s manifest version-requirement line is itself the exact
version already selected — never a range. Read more§impl SourcePolicy for SwiftFormatter
impl SourcePolicy for SwiftFormatter
Source§fn can_resolve_source(&self, source: &DependencySource) -> bool
fn can_resolve_source(&self, source: &DependencySource) -> bool
source. Read moreSource§fn source_is_public_registry_content(&self, source: &DependencySource) -> bool
fn source_is_public_registry_content(&self, source: &DependencySource) -> bool
source’s content is exactly the default public registry’s — safe to treat
as such for OSV vulnerability scanning, cache-key signature construction, and hover
heading links. Read moreAuto Trait Implementations§
impl Freeze for SwiftFormatter
impl RefUnwindSafe for SwiftFormatter
impl Send for SwiftFormatter
impl Sync for SwiftFormatter
impl Unpin for SwiftFormatter
impl UnsafeUnpin for SwiftFormatter
impl UnwindSafe for SwiftFormatter
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
impl<T> EcosystemFormatter for Twhere
T: PackageNaming + PackageRendering + RequirementResolution + DiagnosticMessages + DiagnosticPolicy + SourcePolicy + OsvNaming,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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