pub struct NpmDependency {
pub name: String,
pub name_range: Range,
pub version_req: Option<String>,
pub version_range: Option<Range>,
pub section: NpmDependencySection,
}Expand description
Parsed dependency from package.json with position tracking.
Stores all information about a dependency declaration, including its name, version requirement, and source positions for LSP operations. Positions are critical for features like hover, completion, and inlay hints.
§Examples
use deps_npm::types::{NpmDependency, NpmDependencySection};
use tower_lsp_server::ls_types::{Position, Range};
let dep = NpmDependency {
name: "express".into(),
name_range: Range::new(Position::new(5, 4), Position::new(5, 13)),
version_req: Some("^4.18.2".into()),
version_range: Some(Range::new(Position::new(5, 16), Position::new(5, 25))),
section: NpmDependencySection::Dependencies,
};
assert_eq!(dep.name, "express");
assert!(matches!(dep.section, NpmDependencySection::Dependencies));Fields§
§name: String§name_range: Range§version_req: Option<String>§version_range: Option<Range>§section: NpmDependencySectionTrait Implementations§
Source§impl Clone for NpmDependency
impl Clone for NpmDependency
Source§fn clone(&self) -> NpmDependency
fn clone(&self) -> NpmDependency
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for NpmDependency
impl Debug for NpmDependency
Source§impl Dependency for NpmDependency
impl Dependency for NpmDependency
Source§fn name_range(&self) -> Range
fn name_range(&self) -> Range
LSP range of the dependency name
Source§fn version_requirement(&self) -> Option<&str>
fn version_requirement(&self) -> Option<&str>
Version requirement string (e.g., “^1.0”, “>=2.0”)
Source§fn version_range(&self) -> Option<Range>
fn version_range(&self) -> Option<Range>
LSP range of the version string
Source§fn source(&self) -> DependencySource
fn source(&self) -> DependencySource
Dependency source (registry, git, path)
Source§impl DependencyInfo for NpmDependency
impl DependencyInfo for NpmDependency
Source§fn name_range(&self) -> Range
fn name_range(&self) -> Range
LSP range of the dependency name in the source file.
Source§fn version_requirement(&self) -> Option<&str>
fn version_requirement(&self) -> Option<&str>
Version requirement string (e.g., “^1.0”, “~2.3.4”).
Source§fn version_range(&self) -> Option<Range>
fn version_range(&self) -> Option<Range>
LSP range of the version string (for inlay hints positioning).
Source§fn source(&self) -> DependencySource
fn source(&self) -> DependencySource
Dependency source (registry, git, path).
Source§impl PartialEq for NpmDependency
impl PartialEq for NpmDependency
impl Eq for NpmDependency
impl StructuralPartialEq for NpmDependency
Auto Trait Implementations§
impl Freeze for NpmDependency
impl RefUnwindSafe for NpmDependency
impl Send for NpmDependency
impl Sync for NpmDependency
impl Unpin for NpmDependency
impl UnwindSafe for NpmDependency
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.